<?php
namespace app\madmin\controller;
use app\madmin\model\SystemLogModel;
use app\madmin\model\SystemMemberModel;

/**
 * 日志控制器
 * @author  黄明杰 vx:HMJ125855
 * @version 20190101
 */
class SystemLog extends PublicBase{

	# 日志列表方法
    public function showList(){
        $SystemLog = new SystemLogModel;
        $SystemMember = new SystemMemberModel;

        $Where = $this->getFormWhere();

        $Admin = $this->checkLogin();

        if($Admin['AdminID'] != 1){
            $Where['log_member'] = ['NEQ', 1];
        }

        $Lists = $SystemLog->mList($Where, 'log_id,log_member,log_type,log_msgs,log_state,log_ip,log_create,member_user', config('CNF_LISTPAGE'));

        $Where = [];
        $Where['member_state'] = 1;

        $Admin = $this->checkLogin();

        if($Admin['AdminID'] != 1){
            $Where['member_id'] = ['NEQ', 1];
        }

        return $this->fetch('SystemLog/showList', [
            'Lists' => $Lists,
            'Admin' => $SystemMember->mAll($Where, 'member_id,member_user'),
            'Types' => $this->getLexiconCache('LOGS_TYPE')
        ]);
    }

    # 日志删除方法
    public function showDel(){
    	if(request()->isPost()){
            $SystemLog = new SystemLogModel;

            $ID = input('post.id');

            $Back = $SystemLog->mDel(['log_id'=>$ID]);

            $this->ShowData($Back['code'], $Back['msgs']);
        }
    }

}